import React, { useEffect, useState } from 'react'
import avater from './images/react.png'
export default function Test () {
  const [count, setCount] = useState({
    left: 0,
    top: 0
  })
  useEffect(() => {
    const move = (e) => {
      console.log(1);
      setCount({
        left: e.pageX,
        top: e.pageY
      })
    }
    document.addEventListener('mousemove', move)
    return () => {
      document.removeEventListener('mousemove', move)
    }
  }, [])
  // useEffect(() => {
  //   // count更新之后
  //   console.log(count);
  // }, [count])
  return (
    <div>
      <img style={{
        width: 100,
        position: 'absolute',
        left: count.left - 50,
        top: count.top + 50
      }} src={avater} alt='dva' />
    </div>
  )
}